<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %>
<%@ include file="/admin/include/init_admin.jsp" %>
<%@ page import="com.joinhawaii.admin.product.*" %>
<%
	HashList code001	= CommonUtil.getCodeList("001");	//섬코드
	HashList cRoomType	= CommonUtil.getCodeList("002");	//상품타입
	HashList cHotelType	= CommonUtil.getCodeList("003");	//호텔타입
	HashList cHotelGrade	= CommonUtil.getCodeList("004");	//호텔등급

	String hotel_id		= StringUtil.nvl(request.getParameter("hotel_id"));
	String s_room_id	= StringUtil.nvl(request.getParameter("s_room_id"));
	String s_room_date	= StringUtil.nvl(request.getParameter("s_room_date"));

	HashMap infos = new HashMap();
	infos.put("hotel_id",	hotel_id);

	ProductDAO dao 		= new ProductDAO();
	HashList list 		= dao.selectHotelList(infos);
	HashList roomList 	= dao.selectHotelRoomList(infos);

	infos.put("room_id", s_room_id);
	infos.put("room_date", s_room_date);
	HashList priceList	= dao.selectRoomPriceList(infos);

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title>조인하와이</title>
	<%@ include file="/admin/include/cssnjs.jsp"  %>
	<script type="text/javascript" src="/js/ajaxfileupload.js"></script>
	<script type="text/javascript" src="/SE2.3.1.O9858/js/HuskyEZCreator.js" charset="utf-8"></script>

	<script type="text/javascript">
	var oEditors = [];

	$(document).ready(function() {

		cfInitSE("hotel_info");
		cfInitSE("general_cond");
		cfInitSE("room_info");
		cfInitSE("envi_info");
		cfInitSE("etc_info");

		$('#s_room_date').mask('9999.99.99').datepicker();

		/* 탭 클릭 */
		$('li', '#tabs').click(function(){
		    $('.on', '#tabs').removeClass('on').addClass('off');
		    $(this).addClass('on');

			$('#tabs-1:not(.hidden),#tabs-2:not(.hidden),#tabs-3:not(.hidden),#tabs-4:not(.hidden)').addClass('hidden');
			$('#tabs-'+$(this).attr('code')).removeClass('hidden');
		});

		$('#stopdate').mask('9999.99.99').datepicker();
		$('#canceldate').mask('9999.99.99').datepicker();
		$('#carddate').mask('9999.99.99').datepicker();
		$('#licfromdate').mask('9999.99.99').datepicker();
		$('#licduedate').mask('9999.99.99').datepicker();


		//파일 선택 후 바로 업로드
	//	$('#file').live('change', function(){
		//	ajaxFileUpload();
		//});

		//수정
		$('#update').click(function(){
			fnUpdate()
	    });


	});


	function fnUpdate()
	{
		oEditors.getById["hotel_info"].exec("UPDATE_CONTENTS_FIELD", []);	// 에디터의 내용이 textarea에 적용됩니다.

		if ($('input:radio[name="stat_cd"]:checked').val() == '1') {	//정지
			if ($('#stopdate').val() == '') {
				alert("정지일자를 입력하세요");
				$('#stopdate').focus();
				return false;
			}
			if ($('input:radio[name="stopreason_cd"]:checked').val() == undefined) {
				alert("정지사유를 선택하세요");
				return false;
			}
		}
		else if ($('input:radio[name="stat_cd"]:checked').val() == '2') {	//취소
			if ($('#canceldate').val() == '') {
				alert("취소일자를 입력하세요");
				$('#canceldate').focus();
				return false;
			}
			if ($('#cancelbasis').focus().val() == '') {
				alert("취소근거를 입력하세요");
				return false;
			}
			if ($('#cancelman').focus().val() == '') {
				alert("처분권자를 입력하세요");
				return false;
			}
		}

		if (confirm(MSG_UPDATE)) {
			$('#saveForm').attr('action', './licenseSave.do');
			$('#saveForm').submit();
		}
	}


	function fnCard() {
		if (confirm(MSG_UPDATE)) {
			$('#saveForm').attr('action', './licenseCardSave.do');
			$('#saveForm').submit();
		}
	}

	/* 증명사진 업로드 */
	function ajaxFileUpload() {
        //starting setting some animation when the ajax starts and completes
        $("#file_upload").closest('th').ajaxStart(function(){
						            $(this).showLoading();
						        	})
							        .ajaxComplete(function(){
							            $(this).hideLoading();
							        });

        $.ajaxFileUpload({
            url:'./licensePicUpload.do?userseq=' + $('#userseq').val(),
            secureuri:false,
            fileElementId:'file',
            dataType: 'json',
            success: function (data, status){
            	$('#file_ref').val(data.file_ref);
            	$('#user_image').attr('src','/common/download.do?fileseq='+data.fileseq);
            },
            error: function (data, status, e) {
                alert(e);
            }
        });
	}

	/**화면 출력**/
	function fn_print() {
		cfPrintHtml(document.getElementById('contents').innerHTML);
	}
	</script>
</head>
<body>
<div id="wrap">
	<div id="top">
		<%@ include file="/admin/include/top.jsp" %>
	</div>
	<div id="page">
		<div id="menu">
			<%@ include file="/admin/include/leftMenu.jsp" %>
		</div>
		<div id="contents">
			<div class="menu_title">
				<h1>선택관광</h1>
				<p>관리자 > 상품관리 > <b>선택관광</b></p>
			</div>
			<div class="clear line_01"></div>



			<ul id="tabs" class="tab_01 mt15">
			    <li class="on"  code="1"><p>1. 기본사항</p></li>
			    <li class="off" code="2"><p>2. 상품가격</p></li>
			    <li class="off" code="3"><p>3. 참고사진</p></li>
			</ul>


			<div id="tabs-1" class="mt15">

				<form id="saveForm" method="post" action="">
				<input type="hidden" name="job_type" value="U"/>
				<input type="hidden" name="hotel_id" value="<%= list.get("hotel_id", 0) %>"/>

				<table cellpadding="0" cellspacing="0" class="table_01 mt5">
				<colgroup>
					<col width="100px"/>
					<col width="380px"/>
					<col width="100px"/>
					<col/>
				</colgroup>
				<tbody>
					<tr>
						<th><p>영문명</p></th>
						<td>
							<input type="text" name="hotel_eng_name" value="<%= list.get("hotel_eng_name", 0) %>"  maxlength="255" class="w260"/>
						</td>
						<th><p>한글명</p></th>
						<td class="brx">
							<input type="text" name="hotel_kor_name" value="<%= list.get("hotel_kor_name", 0) %>"  maxlength="255" class="w260"/>
						</td>
					</tr>
					<tr>
						<th><p>호텔타입</p></th>
						<td>
	<%			for (int i = 0; i < cHotelType.size(); i++) {	%>
					<input type="radio" name="hotel_type" value="<%= cHotelType.get("code", i) %>" <%= StringUtil.checked(cHotelType.get("code", i), list.get("hotel_type", 0)) %>><%= cHotelType.get("code_name", i) %>
	<%			}	%>
						</td>
						<th><p>섬위치</p></th>
						<td class="brx">
		        	<select name="land_code" class="w120">
	<%			for (int i = 0; i < code001.size(); i++) {	%>
						<option value="<%= code001.get("code", i) %>" <%= StringUtil.selected(code001.get("code", i), list.get("land_code", 0)) %>><%= code001.get("code_name", i) %></option>
	<%			}	%>
					</select>
						</td>
					</tr>
					<tr>
						<th><p>호텔등급</p></th>
						<td>
					<select name="hotel_grade" class="w120">
	<%			for (int i = 0; i < cHotelGrade.size(); i++) {	%>
						<option value="<%= cHotelGrade.get("code", i) %>" <%= StringUtil.selected(cHotelGrade.get("code", i), list.get("hotel_grade", 0)) %>><%= cHotelGrade.get("code_name", i) %></option>
	<%			}	%>
					</select>
						</td>
						<th><p>상품타입</p></th>
						<td class="brx">
		        	<select name="room_type" class="w120">
	<%			for (int i = 0; i < cRoomType.size(); i++) {	%>
						<option value="<%= cRoomType.get("code", i) %>" <%= StringUtil.selected(cRoomType.get("code", i), list.get("room_type", 0)) %>><%= cRoomType.get("code_name", i) %></option>
	<%			}	%>
					</select>
						</td>
					</tr>
					<tr>
						<th><p>전화</p></th>
						<td><input type="text" name="tel_no" value="<%= list.get("tel_no", 0) %>" maxlength="100" class="w260" /></td>
						<th><p>팩스</p></th>
						<td class="brx"><input type="text" name="fax_no" value="<%= list.get("fax_no", 0) %>" maxlength="100" class="w260" /></td>
					</tr>
					<tr>
						<th><p></p></th>
						<td><input type="text" name="room_cnt" value="<%= list.get("room_cnt", 0) %>" maxlength="6" class="w260"/></td>
						<th><p>최소가격</p></th>
						<td class="brx"><input type="text" name="min_sales_price" value="<%= list.get("min_sales_price", 0) %>" maxlength="100" class="w260" /></td>
					</tr>
					<tr>
						<th><p>주소</p></th>
						<td colspan="3" class="brx"><input type="text" name="addr" value="<%= list.get("addr", 0) %>" style="width:100%" maxlength="500" /></td>
					</tr>
					<tr>
						<th><p>위치</p></th>
						<td colspan="3" class="brx"><input type="text" name="addr_" value="<%= list.get("addr_", 0) %>" style="width:100%" maxlength="500" /></td>
					</tr>
					<tr>
						<th><p>홈페이지</p></th>
						<td colspan="3" class="brx"><input type="text" name="home_page" value="<%= list.get("home_page", 0) %>" style="width:100%" maxlength="500" /></td>
					</tr>
					<tr>
						<th><p>대표사진</p></th>
						<td colspan="3" class="brx">
							<input type="file" name="img_00" value="" class="w300" />
			        		<a href="<%= list.get("img_path_00",0) %>" target="_blank"><%= list.get("img_path_00",0) %></a>
						</td>
					</tr>
					<tr>
						<th><p>호텔정보</p></th>
						<td colspan="3" class="brx">
							<textarea name="hotel_info" id="hotel_info" class="se"><%= list.get("hotel_info", 0).replace("\n","<br/>") %></textarea>
						</td>
					</tr>
					<tr>
						<th><p>호텔규정</p></th>
						<td colspan="3" class="brx">
							<textarea name="general_cond" id="general_cond" class="se"><%= list.get("general_cond", 0).replace("\n","<br/>") %></textarea>
						</td>
					</tr>
					<tr>
						<th><p>객실정보</p></th>
						<td colspan="3" class="brx">
							<textarea name="room_info" id="room_info" class="se"><%= list.get("room_info", 0).replace("\n","<br/>") %></textarea>
						</td>
					</tr>
					<tr>
						<th><p>부대시설</p></th>
						<td colspan="3" class="brx">
							<textarea name="envi_info" id="envi_info" class="se"><%= list.get("envi_info", 0).replace("\n","<br/>") %></textarea>
						</td>
					</tr>
					<tr>
						<th><p>기타</p></th>
						<td colspan="3" class="brx">
							<textarea name="etc_info" id="etc_info" class="se"><%= list.get("etc_info", 0).replace("\n","<br/>") %></textarea>
						</td>
					</tr>
				</tbody>
				</table>

				<div class="mt20 mb10 c">
					<a href="./hotelList.jsp"><img src="/images/admin/btn_list.gif"/></a>
					<a href="#none"><img src="/images/admin/btn_update.gif" id="update" /></a>
				</div>

				</form>

			</div>



			<!-- 상품가격 -->
			<div id="tabs-2" class="hidden mt15">

				<form id="priceSaveForm" method="post" action="./hotelList.jsp">
				<input type="hidden" name="hotel_id" id="hotel_id" value=""/>

				<table cellpadding="0" cellspacing="0" class="table_01 mt15">
				<colgroup>
					<col width="100px" />
					<col width="160px" />
					<col width="100px" />
					<col  />
				</colgroup>
				<tr>
				    <th><p>객실</p></th>
				    <td>
				    	<select name="s_room_id">
	          	  	  	<option value="">전체</option>
	<%			for (int i = 0; i < code001.size(); i++) {	%>
						<option value="<%= code001.get("code", i) %>" <%= StringUtil.selected(code001.get("code", i), s_room_id) %>>
							<%= code001.get("code_name", i) %>
						</option>
	<%			}	%>
					  	</select>
					</td>
					<th><p>숙박일자</p></th>
					<td class="brx">
						<input type="text" name="s_room_date" id="s_room_date" value="<%= s_room_date %>" class="w90 c"/>
					</td>
				</tr>
				</table>

				<div class="mt10 mb10 r">
					<input type="image" class="button" src="/images/admin/btn_search.gif">
				</div>

				<table cellpadding="0" cellspacing="0" class="table_03 mt5">
				<colgroup>
					<col width="40px"/>
					<col/>
					<col width="200px"/>
					<col width="80px"/>
					<col width="80px"/>
					<col width="80px"/>
					<col width="80px"/>
				</colgroup>
				<tbody>
					<tr>
						<th><p><input type="checkbox" name="chkAll" id="chkAll"/></p></th>
						<th><p>객실명</p></th>
						<th><p>시작일</p></th>
						<th><p>종료일</p></th>
						<th><p>price</p></th>
						<th><p>cost</p></th>
						<th><p>b2b</p></th>
						<th class="brx"><p>사용여부</p></th>
					</tr>
				<%	for (int i = 0; i < priceList.size(); i++) { %>
					<tr>
						<td class="c">
							<input type="checkbox" name="chk" />
							<input type="hidden" name="room.room_id" value="<%= priceList.get("room_id", i) %>" />
						</td>
						<td class="l"><input type="text" name="room.room_name" value="<%= priceList.get("room_name", i) %>" class="wmax"/></td>
						<td><input type="text" name="room.room_name" value="<%= priceList.get("room_desc", i) %>" class="wmax"/></td>
						<td><%= priceList.get("room_type", i) %></td>
						<td><input type="text" name="price.cost" value="<%= priceList.get("cost", i) %>" class="wmax"/></td>
						<td><input type="text" name="price.sales_price" value="<%= priceList.get("sales_price", i) %>" class="wmax"/></td>
						<td><input type="text" name="price.b2b_price" value="<%= priceList.get("b2b_price", i) %>" class="wmax"/></td>
						<td class="brx"><%= priceList.get("use_yn", i) %></td>
					</tr>
				<%	} %>
				</tbody>
				</table>

				<div class="mt20 mb10 c">
					<a href="./hotelList.jsp"><img src="/images/admin/btn_list.gif"/></a>
					<img src="/images/admin/btn_addrow.gif" style="cursor:hand" onclick="fnAddRow()"/>
					<img src="/images/admin/btn_delete.gif" style="cursor:hand" onclick="fnDeleteRow()"/>
					<a href="#none"><img src="/images/admin/btn_save.gif" id="updateRoom" /></a>
				</div>

				</form>
			</div>







		</div>
	</div>
</div>

</body>
</html>
